﻿
@{
    ViewBag.Title = "BudgetNotificationAdd";
    Layout = "~/Views/Shared/_LayoutMain.cshtml";
}

@section css {
    <link href="~/Assets/css/lib/bootstrap-select.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/bootstrap-datetimepicker.min.css" rel="stylesheet" />
    <link href="~/Assets/css/lib/fileinput.css" rel="stylesheet" />
    <style>
        th {
            text-align: center;
            font-weight: bold;
        }

        td {
            text-align: center;
            vertical-align: middle;
        }
    </style>
}
<div class="page-content" ng-cloak ng-controller="SafetyCostController" ng-init="GetDepartmentList();SelectedOption=[];
    SearchModel = {};
     page='@(Request.QueryString["page"].IsEmpty() ? "1" : Request.QueryString["page"])';
     PageName = '@Request.CurrentExecutionFilePath.Substring(Request.CurrentExecutionFilePath.LastIndexOf("/") + 1)';
     GetSafetCostApplyFormList(SearchModel,page);
    ">
    <div class="load" ng-show="DataLoading">
        <div class="loader">
            <svg version="1.1" id="loader-1" x="0px" y="0px" width="100px" height="100px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
            <path fill="#000" d="M43.935,25.145c0-10.318-8.364-18.683-18.683-18.683c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615c8.072,0,14.615,6.543,14.615,14.615H43.935z">
            <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite" />
			</path>
		</svg>
            <div class="load-msg" ng-bind="LoadingMsg"></div>
        </div>
    </div>
    <div class="page-heading">
        <h1>费用使用申请</h1>
        <div class="options">
            <div class="btn-toolbar">

            </div>
        </div>
    </div>

    <ol class="breadcrumb">
        <li><a>主页</a></li>
        <li><a>安全费用</a></li>
        <li class="active"><a>费用使用申请</a></li>
    </ol>
    @*<div class="row">
            <div class="col-md-3">
                <a class="info-tiles tiles-inverse has-footer" href="#">
                    <div class="tiles-heading">
                        <div class="pull-left">公司预算</div>
                        <div class="pull-right">
                            <div id="tileorders" class="sparkline-block"><canvas width="39" height="13" style="display: inline-block; width: 39px; height: 13px; vertical-align: top;"></canvas></div>
                        </div>
                    </div>
                    <div class="tiles-body">
                        <div class="text-center" style="font-weight:bold;">1,000,000</div>
                    </div>
                    <div class="tiles-footer">
                        <div class="pull-left"></div>
                        <div class="pull-right percent-change">&nbsp;</div>
                    </div>
                </a>
            </div>
            <div class="col-md-3">
                <a class="info-tiles tiles-orange has-footer" href="#">
                    <div class="tiles-heading">
                        <div class="pull-left">实际使用</div>
                        <div class="pull-right">
                            <div id="tilerevenues" class="sparkline-block"><canvas width="40" height="13" style="display: inline-block; width: 40px; height: 13px; vertical-align: top;"></canvas></div>
                        </div>
                    </div>
                    <div class="tiles-body">
                        <div class="text-center" style="font-weight:bold;">326,040</div>
                    </div>
                    <div class="tiles-footer">
                        <div class="pull-left"></div>
                        <div class="pull-right percent-change">&nbsp;</div>
                    </div>
                </a>
            </div>
            <div class="col-md-3">
                <a class="info-tiles tiles-blue has-footer" href="#">
                    <div class="tiles-heading">
                        <div class="pull-left">剩余预算</div>
                        <div class="pull-right">
                            <div id="tiletickets" class="sparkline-block"><canvas width="13" height="13" style="display: inline-block; width: 13px; height: 13px; vertical-align: top;"></canvas></div>
                        </div>
                    </div>
                    <div class="tiles-body">
                        <div class="text-center" style="font-weight:bold;">673,960</div>
                    </div>
                    <div class="tiles-footer">
                        <div class="pull-left"></div>
                        <div class="pull-right percent-change">&nbsp;</div>
                    </div>
                </a>
            </div>

            <div class="col-md-3">
                <a class="info-tiles tiles-midnightblue has-footer" href="#">
                    <div class="tiles-heading">
                        <div class="pull-left">经费使用率</div>
                        <div class="pull-right">
                            <div id="tilemembers" class="sparkline-block"><canvas width="39" height="13" style="display: inline-block; width: 39px; height: 13px; vertical-align: top;"></canvas></div>
                        </div>
                    </div>
                    <div class="tiles-body">
                        <div class="text-center" style="font-weight:bold;">33%</div>
                    </div>
                    <div class="tiles-footer">
                        <div class="pull-left"></div>
                        <div class="pull-right percent-change">&nbsp;</div>
                    </div>
                </a>
            </div>
        </div>*@
    <div class="container-fluid">
        <div class="row">
            <form class="form-horizontal row-border">
                <div class="col-md-12">
                    <div class="panel panel-default">
                        <div class="panel-heading"><h2>筛选条件</h2></div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-1 control-label">年份：</label>
                                <div class="col-sm-2">
                                    <select id="Dep_Select" class="form-control" ng-model="SearchModel.Years" data-live-search="true">
                                        <option value="" selected>所有年份</option>
                                    </select>
                                </div>
                                <label class="col-sm-1 control-label">部门：</label>
                                <div class="col-sm-2">
                                    <select class="form-control" ng-model="SearchModel.ParkId" data-live-search="true">
                                        <option value="" selected>所有部门</option>
                                        <option ng-repeat="x in ParkList" value="{{x.Id}}">{{x.ParkName}}</option>
                                    </select>
                                </div>
                                <button class="btn btn-primary">查询</button>
                            </div>
                        </div>
                    </div>
                </div>
            </form>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div id="step"></div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-12">
                <div class="panel panel-sky">
                    <div class="panel-heading">
                        <h2>费用使用申请 总数：<b ng-bind="TotalCount"></b></h2>
                        <div class="panel-ctrls">
                            <div class="btn-group">
                                <a href="SafetyCostApply?page={{result.currentPage}}" class="btn btn-xs btn-primary"><i class="fa fa-plus"></i>费用使用申请</a>
                            </div>
                        </div>
                    </div>
                    <div class="panel-body">
                        <table class="table table-striped table-bordered table-hover" ng-show="!PageLoading">
                            <thead>
                                <tr style="background-color:blueviolet;">
                                    <th style="width:2%">序号</th>
                                    <th style="width:5%">使用部门</th>
                                    <th style="width:5%">填报人</th>
                                    <th style="width:15%">使用范围</th>
                                    <th style="width:5%">预算使用金额</th>
                                    <th style="width:5%">实际使用金额</th>
                                    <th style="width:5%">状态</th>
                                    <th style="width:10%">操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr ng-show="DataList.length==0 && !DataLoading">
                                    <td colspan="12" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                </tr>
                                <tr ng-repeat="x in DataList">
                                    <td>{{$index+1}}</td>
                                    <td>{{x.DepartmentName}}</td>
                                    <td>{{x.CreateUserName}}</td>
                                    <td><a ng-click="ShowRangeInfo(x.ApplyItems);" href="#UsageRangeModal" data-toggle="modal"><span ng-repeat="y in x.ApplyItems">{{y.RangeModel.Title}}; </span></a></td>
                                    <td>{{x.TotalAmount}}</td>
                                    <td>{{x.TotalCost}}</td>
                                    <td><span class="label label-primary">{{x.StatusName}}</span></td>
                                    <td>
                                        <a ng-if="x.IsShowApprove" href="SafetyCostApprove?Id={{x.Id}}&page={{result.currentPage}}&pagename={{PageName}}" class="btn btn-primary btn-xs btn-label"><i class="fa fa-flag"></i>审核</a>
                                        <a ng-if="x.Status==100" ng-click="ShowCostList(x.ApplyItems);" href="#FillAmount" data-toggle="modal" class="btn btn-primary btn-xs btn-label"><i class="fa fa-money"></i>实际使用</a>
                                        <a href="SafetyCostRecordDetail?Id={{x.Id}}&page={{result.currentPage}}" class="btn btn-default btn-xs btn-label"><i class="fa fa-search"></i>查看</a>
                                        <a ng-if="x.Status==0" ng-click="DeleteSafetyCostApply(x.Id,SearchModel,result.currentPage);" class="btn btn-danger btn-xs btn-label"><i class="fa fa-trash"></i>删除</a>
                                        <a ng-if="x.Status==1 && User.UserNo==x.CreateUser" ng-click="RecallSafetyCostApply(x.Id);" class="btn btn-danger btn-xs btn-label"><i class="fa fa-mail-reply"></i>撤回</a>
                                        <a ng-if="x.Status==0" href="SafetyCostRecordEdit?Id={{x.Id}}&page={{result.currentPage}}" class="btn btn-warning btn-xs btn-label"><i class="fa fa-pencil-square"></i>编辑</a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="text-center" ng-show="DataList!=null && DataList.length>0">
                    <ul class="pagination  justify-content-center">
                        <li class="page-item"><a class="page-link" style="cursor:pointer;" ng-click="GetConstructionPageList(SearchModel,1);">首页</a></li>
                        <li class="page-item" ng-class="{'active':result.currentPage==page}" ng-repeat="page in result.pages"><a style="cursor:pointer;" ng-click="GetConstructionPageList(SearchModel,page)" class="page-link" ng-bind="page"></a></li>
                        <li class="page-item"><a class="page-link" style="cursor:pointer;" ng-click="GetConstructionPageList(SearchModel,(result.currentPage + 1 > result.totalPage ? result.totalPage : result.currentPage + 1))">下一页</a></li>
                        <li class="page-item"><a class="page-link" style="cursor:pointer;" ng-click="GetConstructionPageList(SearchModel,result.totalPage);">尾页</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="modal fade" id="FillAmount" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:1250px;">
            <div class="modal-content" style="min-height: 700px;overflow-y:scroll;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">设置实际使用金额</h2>
                </div>
                <div class="modal-body" style="min-height: 660px;">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <table class="table table-striped table-bordered table-hover">
                                <thead>
                                    <tr>
                                        <th style="width:5%">序号</th>
                                        <th style="width:30%">使用范围</th>
                                        <th style="width:10%">事由</th>
                                        <th style="width:10%">预计金额</th>
                                        <th style="width:10%">使用金额</th>
                                        <th style="width:10%">备注</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <tr ng-show="CostList==0">
                                        <td colspan="4" style="text-align:center;vertical-align:middle;line-height:30px;">没有数据</td>
                                    </tr>
                                    <tr ng-repeat="x in CostList">
                                        <td>{{$index+1}}</td>
                                        <td>{{x.RangeModel.Title +'.'+ x.RangeModel.Content}}</td>
                                        <td>{{x.Option}}</td>
                                        <td>{{x.Amount}} {{x.Amount|TransCurrency}}</td>
                                        <td><input type="number" class="form-control" ng-model="x.CostAmount" ng-change="CalcTotal(CostList);" /></td>
                                        <td>{{x.Remark}}</td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">合计</td>
                                        <td>{{totalAmount}} {{totalAmount|TransCurrency}}</td>
                                        <td>{{TotalCost}} {{TotalCost|TransCurrency}}</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close">关闭</button>
                    <button type="button" class="btn btn-primary" data-dismiss="modal" ng-click="UpdateCostItems(CostList[0].FormId,CostList,SearchModel,result.currentPage);">保存</button>
                </div>
            </div>

        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <div class="modal fade" id="UsageRangeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="min-width:1250px;">
            <div class="modal-content" style="min-height: 700px;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h2 class="modal-title">使用范围</h2>
                </div>
                <div class="modal-body" style="min-height: 660px;">
                    <div class="form-group">
                        <div class="col-sm-12">
                            <p ng-repeat="x in CurrentItems">{{x.RangeModel.Title}}.{{x.RangeModel.Content}}</p>
                        </div>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" id="btn_close">关闭</button>
                </div>
            </div>

        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    
</div>

@section Js{
    <script src="~/Assets/plugins/form-ckeditor/ckeditor.js"></script>
    <script src="~/Assets/js/libs/upload.js"></script>
    <script src="~/Assets/js/pg/SafetyCost.js?v=@DateTime.Now.ToString("yyMMddHHmm")"></script>
    <script src="~/Assets/js/libs/moment.min.js"></script>
    <script src="~/Assets/js/libs/locales/date/zh-cn.js"></script>
    <script src="~/Assets/js/libs/bootstrap-datetimepicker.min.js"></script>
    <script src="~/Assets/js/libs/angularjs-datepicker.js"></script>
    <script src="~/Assets/js/libs/fileinput.js"></script>
    <script src="~/Assets/js/libs/zh.js"></script>
    <script>
        $('#SelectedCheckList').sortable({
            connectWith: ".sortable-connected",
            receive: function (event, ui) {
                var lists = $('.sortable-connected');
                for (var i = lists.length - 1; i >= 0; i--) {
                    if ($(lists[i]).children().length < 1) $(lists[i]).html('');
                };
            }
        });
    </script>
}
        